Option Explicit On
Option Strict On

Imports CObject
Imports System.Data.SqlClient
Imports ConnectionServer

Namespace Security

    Public Enum eRoleType
        NoneSpecified = 0
        Submitter = 1
        Processor = 2
        Admin = 3
        Reader = 4
        'add addtional type here as needed. also add to SEC_RoleTypes
    End Enum

    ''' -----------------------------------------------------------------------------
    ''' <summary>
    ''' The Role class represents a set of permissions for a group of users.
    ''' </summary>
    ''' <remarks>
    ''' </remarks>
    ''' <history>
    ''' 	 	2/13/2004	Created
    ''' </history>
    ''' 
    Public Class Role
        Inherits CObject.CObject

        Private moRoleObjectIDs As ArrayList
        Private mdtExecptionDefaults As DataTable
        Private mdtUserDefaults As DataTable

        Private Sub Init()
            delAfterSave = New AfterSaveHandler(AddressOf AfterSave)
        End Sub

        Public Sub New()
            MyBase.New()
            Init()
        End Sub

        Public Sub New(ByVal piRoleID As Integer)
            MyBase.New(piRoleID)
            Init()
        End Sub

        Public Sub New(ByVal psRoleName As String)
            Dim loColl As CCollection = New CCollection(New Role, "NAME = '" & psRoleName & "'")
            If Not loColl.DataObject Is Nothing Then
                MyBase.mhtProperties = loColl.DataObject.Properties
            End If
            Init()
        End Sub

        Public Overrides ReadOnly Property Key() As String
            Get
                Return "RoleID"
            End Get
        End Property

        Protected Overrides Function ProcedureSigniture(ByVal peCommandType As CObject.CommandType) As String
            Select Case peCommandType
                Case CommandType.SQLSelect
                    Return "SELECT * from vwSEC_Roles"
                Case CommandType.SQLInsert, CommandType.SQLUpdate
                    Return "EXEC UPDATE_Role {ContactLevel},{ApplicationID},{Name},{Description},{BU},{Effective_DT},{RoleID}"
                Case CommandType.SQLDelete
                    Return "EXEC dbo.SEC_DeleteRole {RoleID}"
                Case Else
                    Throw New Exception("Invalid commandType")
            End Select
        End Function

        Public Overrides ReadOnly Property SourceDataBase() As ConnectionServer.Connection.SourceDataBase
            Get
                Return ConnectionServer.Connection.SourceDataBase.CMT
            End Get
        End Property

        Public Overrides Function Clone() As CObject.CObject
            Return New Role
        End Function

        Protected Overrides Sub Finalize()
            MyBase.Finalize()
        End Sub

#Region "Properties"
        ''' <summary>
        ''' The type of role
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public ReadOnly Property RoleType() As eRoleType
            Get
                Return CType(CastToInteger(GetProperty("RoleType")), eRoleType)
            End Get
        End Property

        Public ReadOnly Property ExceptionDefaults() As DataTable
            Get
                If mdtExecptionDefaults Is Nothing Then
                    Dim loColl As CCollection = New CCollection(New ExceptionDefault, "GroupID=" & RoleID.ToString, True)
                    mdtExecptionDefaults = loColl.DataTable
                End If
                Return mdtExecptionDefaults
            End Get
        End Property

        Public ReadOnly Property UserDefaults() As DataTable
            Get
                If mdtUserDefaults Is Nothing Then
                    Dim loColl As CCollection = New CCollection(New UserDefault, "GroupID=" & RoleID.ToString, True)
                    mdtUserDefaults = loColl.DataTable
                End If
                Return mdtUserDefaults
            End Get
        End Property

        ''' -----------------------------------------------------------------------------
        ''' <summary>
        ''' The Unique ID for each role
        ''' </summary>
        ''' <remarks>
        ''' </remarks>
        ''' <history>
        ''' 	 	2/13/2004	Created
        ''' </history>
        ''' 
        Public Property RoleID() As Integer
            Get
                Return CInt(GetProperty("RoleID"))
            End Get
            Set(ByVal Value As Integer)
                SetProperty(CStr(RoleID), Value)

            End Set
        End Property

        ''' -----------------------------------------------------------------------------
        ''' <summary>
        ''' The name of each role
        ''' </summary>
        ''' <remarks>
        ''' </remarks>
        ''' <history>
        ''' 	 	2/13/2004	Created
        ''' </history>
        ''' 
        Public Property Name() As String
            Get
                If Not IsDBNull(GetProperty("Name")) Then
                    Return CStr(GetProperty("Name"))
                Else
                    Return ""
                End If
            End Get
            Set(ByVal Value As String)
                SetProperty("Name", Value)
            End Set
        End Property

        ''' -----------------------------------------------------------------------------
        ''' <summary>
        ''' Describes the role and what it is used for.
        ''' </summary>
        ''' <remarks>
        ''' </remarks>
        ''' <history>
        ''' 	 	2/13/2004	Created
        ''' </history>
        ''' 
        Public Property Description() As String
            Get
                If Not IsDBNull(GetProperty("Description")) Then
                    Return CStr(GetProperty("Description"))
                Else
                    Return ""
                End If
            End Get
            Set(ByVal Value As String)
                SetProperty("Description", Value)
            End Set
        End Property


        ''' -----------------------------------------------------------------------------
        ''' <summary>
        ''' The Contact level of this Role (Admin 1 or Admin 2)
        ''' </summary>
        ''' <value></value>
        ''' <remarks>
        ''' Admin 2 can say who admin 1 is.
        ''' </remarks>
        ''' <history>
        ''' 	 	3/2/2005	Created
        ''' </history>
        ''' -----------------------------------------------------------------------------
        Public Property ContactLevel() As Integer
            Get
                Return CastToInteger(GetProperty("ContactLevel"))
            End Get
            Set(ByVal Value As Integer)
                SetProperty("ContactLevel", Value)
            End Set
        End Property

        ''' -----------------------------------------------------------------------------
        ''' <summary>
        ''' The Offline Contact level of this Role (Admin 1 or Admin 2)
        ''' </summary>
        ''' <value></value>
        ''' <remarks>
        ''' Admin 2 can say who admin 1 is.
        ''' </remarks>
        ''' <history>
        ''' 	 	3/2/2005	Created
        ''' </history>
        ''' -----------------------------------------------------------------------------
        Public Property OfflineContactLevel() As Integer
            Get
                Return CastToInteger(GetProperty("OfflineContactLevel"))
            End Get
            Set(ByVal Value As Integer)
                SetProperty("OfflineContactLevel", Value)
            End Set
        End Property

        ''' -----------------------------------------------------------------------------
        ''' <summary>
        ''' The Application ID this role belongs to
        ''' </summary>
        ''' <value></value>
        ''' <remarks>
        ''' </remarks>
        ''' <history>
        ''' 	 	3/2/2005	Created
        ''' </history>
        ''' -----------------------------------------------------------------------------
        Public Property ApplicationID() As Integer
            Get
                Return CastToInteger(GetProperty("ApplicationID"))
            End Get
            Set(ByVal Value As Integer)
                SetProperty("ApplicationID", Value)
            End Set
        End Property

        ''' <summary>
        ''' Effective Date
        ''' </summary>
        ''' <value></value>
        ''' <returns> Date time</returns>
        ''' <remarks></remarks>
        Public Property EffectiveDate() As DateTime
            Get
                CastToDate(GetProperty("Effective_DT"))
            End Get
            Set(ByVal Value As DateTime)
                SetProperty("Effective_DT", Value)
            End Set
        End Property

        Public Property Country() As String
            Get
                Return CastToString(GetProperty("Country"))
            End Get
            Set(ByVal value As String)
                SetProperty("Country", value)
            End Set
        End Property

        ''' -----------------------------------------------------------------------------
        ''' <summary>
        ''' Returns a CDataTable of objects this role has security for.
        ''' </summary>
        ''' <remarks>
        ''' </remarks>
        ''' <history>
        ''' 	 	2/13/2004	Created
        ''' </history>
        ''' 
        Public ReadOnly Property RoleObjects() As CDataTable
            Get
                Dim lsObjectIDs As String = String.Empty
                Dim lsRoleObjectID As String = String.Empty
                If Not RoleObjectsIDs Is Nothing Then
                    If RoleObjectsIDs.Count > 0 Then
                        Dim loArrIDs As ArrayList = RoleObjectsIDs
                        For Each lsRoleObjectID In loArrIDs
                            lsObjectIDs += "," & lsRoleObjectID
                        Next
                        lsObjectIDs = lsObjectIDs.Substring(1)
                        Dim loColl As CCollection = New CCollection(New SecurityObject, "ObjectID in (" & lsObjectIDs & ")")
                        Return loColl.CDatatable
                    End If
                    Return Nothing
                End If
                Return Nothing
            End Get
        End Property

        ''' -----------------------------------------------------------------------------
        ''' <summary>
        ''' Returns the ObjectID's this role has security for
        ''' </summary>
        ''' <remarks>
        ''' </remarks>
        ''' <history>
        ''' 	 	2/13/2004	Created
        ''' </history>
        ''' 
        Public Property RoleObjectsIDs() As ArrayList
            Get
                Dim loConnServer As ConnectionServer.Connection = New ConnectionServer.Connection
                Dim loConn As SqlConnection = loConnServer.GetConnection(ConnectionServer.Connection.SourceDataBase.CMT)
                Dim loComm As SqlCommand = New SqlCommand("SEC_GetRoleObjects " & RoleID, loConn)
                Dim loDR As SqlDataReader = loComm.ExecuteReader(CommandBehavior.CloseConnection)
                moRoleObjectIDs = New ArrayList
                Do While loDR.Read
                    moRoleObjectIDs.Add(loDR(0))
                Loop
                loDR.Close()
                Return moRoleObjectIDs
            End Get
            Set(ByVal value As ArrayList)
                moRoleObjectIDs = value
            End Set
        End Property

#End Region

#Region "Methods"

        Public Function GetRoleMembersBySecureViewData(ByVal piParentObjectID As Integer, ByVal psViewData As String, Optional ByVal piRoleID As Integer = 0) As DataTable

            Dim lsSQL As String = String.Empty
            Dim loDT As DataTable = New DataTable

            If piRoleID = 0 Then
                lsSQL = "EXEC SEC_GetRoleMembersBySecureViewData " & RoleID.ToString & "," & piParentObjectID.ToString & ",'" & psViewData & "'"
            Else
                lsSQL = "EXEC SEC_GetRoleMembersBySecureViewData " & piRoleID.ToString & "," & piParentObjectID.ToString & ",'" & psViewData & "'"
            End If

            Using loConnection As ConnectionServer.Connection = New ConnectionServer.Connection
                Dim loConn As SqlConnection = loConnection.GetConnection(ConnectionServer.Connection.SourceDataBase.CMT)
                Dim loAdp As SqlDataAdapter = New SqlDataAdapter(New SqlCommand(lsSQL, loConn))
                loAdp.Fill(loDT)
                loConn.Close()
            End Using

            Return loDT

        End Function

        Public Function GetRoleMembersBySecureViewDataAll(ByVal piParentObjectID As Integer, Optional ByVal piRoleID As Integer = 0) As DataTable

            Dim lsSQL As String = String.Empty
            Dim loDT As DataTable = New DataTable

            If piRoleID = 0 Then
                lsSQL = "EXEC SEC_GetRoleMembersBySecureViewDataAll " & RoleID.ToString & "," & piParentObjectID.ToString
            Else
                lsSQL = "EXEC SEC_GetRoleMembersBySecureViewDataAll " & piRoleID.ToString & "," & piParentObjectID.ToString
            End If

            Using loConnection As ConnectionServer.Connection = New ConnectionServer.Connection
                Dim loConn As SqlConnection = loConnection.GetConnection(ConnectionServer.Connection.SourceDataBase.CMT)
                Dim loAdp As SqlDataAdapter = New SqlDataAdapter(New SqlCommand(lsSQL, loConn))
                loAdp.Fill(loDT)
                loConn.Close()
            End Using

            Return loDT

        End Function

       

        Public Function GetRoleMembers() As DataTable

            Dim lsSQL As String = "EXEC SEC_GetRoleMembers " & RoleID
            Dim loConnection As ConnectionServer.Connection = New ConnectionServer.Connection
            Dim loConn As SqlConnection = loConnection.GetConnection(ConnectionServer.Connection.SourceDataBase.CMT)
            Dim loDT As DataTable = New DataTable
            Dim loAdp As SqlDataAdapter = New SqlDataAdapter(New SqlCommand(lsSQL, loConn))
            loAdp.Fill(loDT)
            loConn.Close()
            Return loDT

        End Function

        Public Function GetRoleMembersData() As DataTable

            Dim lsSQL As String = "EXEC SEC_GetRoleMembersData " & RoleID.ToString & ",''"
            Using loConn As ConnectionServer.Connection = New ConnectionServer.Connection(ConnectionServer.Connection.SourceDataBase.CMT)
                Return loConn.GetDataTable(lsSQL)
            End Using

        End Function

        Public Function GetRoleMembersData(ByVal psFilter As String) As DataTable

            Dim lsSQL As String = "EXEC SEC_GetRoleMembersData " & RoleID.ToString & ",'" & psFilter & "'"
            Using loConn As ConnectionServer.Connection = New ConnectionServer.Connection(ConnectionServer.Connection.SourceDataBase.CMT)
                Return loConn.GetDataTable(lsSQL)
            End Using

        End Function

        Public Function GetUserRightsDefaults() As DataTable

            Dim lsSQL As String = "EXEC SEC_GetUserRightsDefaults " & RoleID.ToString
            Dim loDT As DataTable = New DataTable
            Using loConnection As ConnectionServer.Connection = New ConnectionServer.Connection
                Dim loConn As SqlConnection = loConnection.GetConnection(ConnectionServer.Connection.SourceDataBase.CMT)
                Dim loAdp As SqlDataAdapter = New SqlDataAdapter(New SqlCommand(lsSQL, loConn))
                loAdp.Fill(loDT)
                loConn.Close()
            End Using
            Return loDT

        End Function

        Public Function GetAllRoles() As DataTable

            Dim loColl As CCollection = New CCollection(New Role, True)
            Return loColl.DataTable

        End Function

        Public Function GetAllRoles(ByVal psSearchString As String) As DataTable

            Dim loColl As CCollection = New CCollection(New Role, " GROUPS like '%" & psSearchString.Replace("'", "''") & "%' ", True)
            Return loColl.DataTable

        End Function

        Public Function GetAllRolesByBU(ByVal psBU As String) As DataTable

            Dim loColl As CCollection = New CCollection(New Role, " BU = '" & psBU & "' ", True)
            Return loColl.DataTable

        End Function

        Public Sub RemoveDefault(ByVal piDefaultID As Integer)

            Dim lsSQL As String = "EXEC DELETE_UserRightsDefault " & piDefaultID
            Dim loConn As Connection = New Connection(Connection.SourceDataBase.CMT)
            loConn.ExecuteScalar(lsSQL)

        End Sub

        Public Sub RemoveMember(ByVal psGUI As String)

            Dim lsSQL As String = "EXEC DELETE_UserRight " & RoleID.ToString & ",'" & psGUI & "'"
            Dim loConn As Connection = New Connection(Connection.SourceDataBase.CMT)
            loConn.ExecuteScalar(lsSQL)

        End Sub

        Public Sub AddMemeber(ByVal psGUI As String)

            Dim lsSQL As String = "EXEC INSERT_UserRight " & RoleID & ",'" & psGUI & "'"
            Dim loConn As Connection = New Connection(Connection.SourceDataBase.CMT)
            loConn.ExecuteScalar(lsSQL)

        End Sub

        Private Sub AfterSave(ByVal poObject As CObject.CObject, ByVal liTRan As SqlTransaction, ByVal idbConn As SqlConnection)
            For Each loRow As DataRow In ExceptionDefaults.Rows
                Dim ExDef As ExceptionDefault
                If Not IsDBNull(loRow("DefaultID")) Then
                    ExDef = New ExceptionDefault(CInt(loRow("DefaultID")))
                Else
                    ExDef = New ExceptionDefault
                End If

                ExDef.GroupID = RoleID
                ExDef.LOCATION = loRow("LOCATION").ToString
                ExDef.GUI = loRow("GUI").ToString
                Select Case loRow.RowState
                    Case DataRowState.Modified, DataRowState.Added
                        ExDef.Save()
                    Case DataRowState.Deleted
                        ExDef.Delete()
                End Select

            Next
            For Each loRow As DataRow In UserDefaults.Rows
                Dim Def As UserDefault
                If Not IsDBNull(loRow("ID")) Then
                    Def = New UserDefault(CInt(loRow("ID")))
                Else
                    Def = New UserDefault
                End If
                Def.GroupID = RoleID
                Def.LOCATION = loRow("LOCATION").ToString
                Def.GUI = loRow("GUI").ToString
                Select Case loRow.RowState
                    Case DataRowState.Modified, DataRowState.Added
                        Def.Save()
                    Case DataRowState.Deleted
                        Def.Delete()
                End Select

            Next

        End Sub

        ''' -----------------------------------------------------------------------------
        ''' <summary>
        ''' Validates if a user is in the current Role
        ''' </summary>
        ''' <remarks>
        ''' </remarks>
        ''' <history>
        ''' 	 	2/13/2004	Created
        ''' </history>
        ''' 
        Public Function ValidateGUI(ByVal psGUI As String) As Boolean

            Dim lsSQL As String = "EXEC SEC_ValidateGUI " & RoleID & ",'" & psGUI & "'"
            Dim loConnServer As ConnectionServer.Connection = New ConnectionServer.Connection()
            Dim loComm As SqlCommand = loConnServer.Command(lsSQL)
            loComm.Connection = loConnServer.GetConnection(Connection.SourceDataBase.CMT)

            Return CBool(loComm.ExecuteScalar())

        End Function

        Public Sub AddSecObject(ByVal poObject As SecurityObject)

            Dim loConn As ConnectionServer.Connection = New ConnectionServer.Connection(ConnectionServer.Connection.SourceDataBase.CMT)

            Using loComm As SqlCommand = loConn.Command("EXEC SEC_InsertRoleObject " & Me.RoleID.ToString & "," & poObject.ObjectID.ToString)
                loComm.ExecuteNonQuery()
                loComm.Connection.Close()
            End Using

        End Sub

        Public Sub RemoveSecObject(ByVal poObject As SecurityObject)

            Dim loConn As Connection = New Connection(Connection.SourceDataBase.CMT)
            Using loComm As SqlCommand = loConn.Command("EXEC DELETE_RolePermission " & RoleID.ToString & "," & poObject.ObjectID.ToString)
                loComm.ExecuteNonQuery()
                loComm.Connection.Close()
            End Using

        End Sub

        ''' -----------------------------------------------------------------------------
        ''' <summary>
        ''' SAves the Role Objects Array in its current state
        ''' </summary>
        ''' <param name="poTran"></param>
        ''' <param name="poConn"></param>
        ''' <remarks>
        ''' </remarks>
        ''' <history>
        ''' 	 	3/2/2005	Created
        ''' </history>
        ''' -----------------------------------------------------------------------------
        Public Sub SaveRoleObjects(ByVal poTran As IDbTransaction, ByVal poConn As IDbConnection)
            Dim loConn As SqlConnection = CType(poConn, SqlConnection)
            Dim loTran As SqlTransaction = CType(poTran, SqlTransaction)
            Dim loComm As SqlCommand = New SqlCommand("EXEC SEC_ClearRoleObjects " & RoleID.ToString, loConn, loTran)
            loComm.ExecuteNonQuery()
            Dim liObjectID As Integer
            For Each liObjectID In moRoleObjectIDs
                loComm = New SqlCommand("EXEC SEC_InsertRoleObject " & Me.RoleID.ToString & "," & liObjectID.ToString, loConn, loTran)
                loComm.ExecuteNonQuery()
            Next

        End Sub

        ''' -----------------------------------------------------------------------------
        ''' <summary>
        ''' Deletes all members from the Group
        ''' </summary>
        ''' <param name="poTran"></param>
        ''' <param name="poConn"></param>
        ''' <remarks>
        ''' </remarks>
        ''' <history>
        ''' 	 	3/2/2005	Created
        ''' </history>
        ''' -----------------------------------------------------------------------------
        Public Sub ClearMembers(ByVal poTran As IDbTransaction, ByVal poConn As IDbConnection)

            ExecuteSQL(poTran, poConn, "EXEC DELETE_Role_Exceptions " & RoleID.ToString)

        End Sub

        ''' -----------------------------------------------------------------------------
        ''' <summary>
        ''' Adds a member to the group
        ''' </summary>
        ''' <param name="psGUI"></param>
        ''' <param name="poTran"></param>
        ''' <param name="poConn"></param>
        ''' <remarks>
        ''' </remarks>
        ''' <history>
        ''' 	 	3/2/2005	Created
        ''' </history>
        ''' -----------------------------------------------------------------------------
        Public Sub SaveMember(ByVal psGUI As String, ByVal poTran As IDbTransaction, ByVal poConn As IDbConnection)
            ExecuteSQL(poTran, poConn, "EXEC USER_AddToRole '" & psGUI & "'," & Me.RoleID & "")
        End Sub

        Public Sub SaveMember(ByVal psGUI As String)
            Dim loConn As SqlConnection = New ConnectionServer.Connection(ConnectionServer.Connection.SourceDataBase.CMT).Connection
            Dim loComm As SqlCommand = New SqlCommand("EXEC USER_AddToRole '" & psGUI & "'," & Me.RoleID & "", loConn)
            loComm.ExecuteNonQuery()
            loConn.Close()
        End Sub

        Private Sub ExecuteSQL(ByVal poTRan As IDbTransaction, ByVal poConn As IDbConnection, ByVal lsSQL As String)
            Dim loConn As SqlConnection = CType(poConn, SqlConnection)
            Dim loTran As SqlTransaction = CType(poTRan, SqlTransaction)
            Dim loComm As SqlCommand = New SqlCommand(lsSQL, loConn, loTran)
            loComm.ExecuteNonQuery()
        End Sub

#End Region

    End Class

    Public Class UserDefault
        Inherits CObject.CObject

        Public Sub New(ByVal piID As Integer)
            MyBase.New(piID)
        End Sub

        Public Sub New()
            MyBase.New()
        End Sub

        Public Overrides Function Clone() As CObject.CObject
            Return New UserDefault
        End Function

        Public Overrides ReadOnly Property Key() As String
            Get
                Return "ID"
            End Get
        End Property

        Public Overrides ReadOnly Property SourceDataBase() As ConnectionServer.Connection.SourceDataBase
            Get
                Return ConnectionServer.Connection.SourceDataBase.CMT
            End Get
        End Property

#Region "Properties"

        Public Property GroupID() As Integer
            Get
                Return CastToInteger(GetProperty("GroupID"))
            End Get
            Set(ByVal value As Integer)
                SetProperty("GroupID", value)
            End Set
        End Property

        Public Property LOCATION() As String
            Get
                Return CastToString(GetProperty("LOCATION"))
            End Get
            Set(ByVal value As String)
                SetProperty("LOCATION", value)
            End Set
        End Property

        Public Property GUI() As String
            Get
                Return CastToString(GetProperty("GUI"))
            End Get
            Set(ByVal value As String)
                SetProperty("GUI", value)
            End Set
        End Property

        Public Property ID() As Integer
            Get
                Return CastToInteger(GetProperty("ID"))
            End Get
            Set(ByVal value As Integer)
                SetProperty("ID", value)
            End Set
        End Property

#End Region

        Protected Overrides Function ProcedureSigniture(ByVal peCommandType As CObject.CommandType) As String
            Select Case peCommandType
                Case Else
                    Throw New Exception("Invalid CommandType")
            End Select
        End Function

    End Class

    Public Class ExceptionDefault
        Inherits CObject.CObject

        Public Sub New(ByVal piDefaultID As Integer)
            MyBase.New(piDefaultID)
        End Sub

        Public Sub New()
            MyBase.New()
        End Sub

        Public Overrides Function Clone() As CObject.CObject
            Return New ExceptionDefault
        End Function

        Public Overrides ReadOnly Property Key() As String
            Get
                Return "DefaultID"
            End Get
        End Property

        Public Overrides ReadOnly Property SourceDataBase() As ConnectionServer.Connection.SourceDataBase
            Get
                Return ConnectionServer.Connection.SourceDataBase.CMT
            End Get
        End Property

#Region "Properties"

        Public Property GroupID() As Integer
            Get
                Return CastToInteger(GetProperty("GroupID"))
            End Get
            Set(ByVal value As Integer)
                SetProperty("GroupID", value)
            End Set
        End Property

        Public Property LOCATION() As String
            Get
                Return CastToString(GetProperty("LOCATION"))
            End Get
            Set(ByVal value As String)
                SetProperty("LOCATION", value)
            End Set
        End Property

        Public Property GUI() As String
            Get
                Return CastToString(GetProperty("GUI"))
            End Get
            Set(ByVal value As String)
                SetProperty("GUI", value)
            End Set
        End Property

        Public Property DefaultID() As Integer
            Get
                Return CastToInteger(GetProperty("DefaultID"))
            End Get
            Set(ByVal value As Integer)
                SetProperty("DefaultID", value)
            End Set
        End Property

#End Region

        Protected Overrides Function ProcedureSigniture(ByVal peCommandType As CObject.CommandType) As String
            Select Case peCommandType
                Case Else
                    Throw New Exception("Invalid CommandType")
            End Select
        End Function
    End Class
End Namespace